import React from 'react';
import { connect } from 'dva';
import styles from './mine_home.less';
import { NavBar, Icon } from 'antd-mobile';
import { API_HOST , getAgentsId} from '../../settings'
import axios from '../../utils/axiosUtil'
import HomeBottom from './../index/home_bottom/home_bottom';


@connect(({global}) => ({
    global
}))
export default class Mine_home extends React.Component {
constructor() {
    super()
    this.state = {
      loading:true,
      isOk:false
    }
  }
  timer = '';
  render() {
    document.title = '我的'
    return (
      <div className={styles.mine_all}>

         {/*<NavBar
            mode="light"
            icon={<Icon type="left" onClick={() => { this.props.history.goBack() }} />}
            onLeftClick={() => console.log('onLeftClick')}>我的
         </NavBar>*/}


<div className={styles.mine_cencon}>
        <a href="#/Mine_all">
          <div className={styles.mine_eve}>
              <div className={styles.mine_left}>
                  <img src="./img/mine_one.jpg" alt="" className={styles.mine_imgl} />
                  <div className={styles.mine_text}>全部订单</div>
              </div>
              <img src="./img/in.png" alt="" className={styles.mine_rig}/>
          </div>
        </a>

        <div className={styles.mine_eve} onClick={()=>{
            console.log(this.props.global.BusinessInfo.phoneNumber)
            window.YLJsBridge.call(
            'callTel',
            {phoneNum:this.props.global.BusinessInfo.phoneNumber}
            )
          }}>
          <div className={styles.mine_left}>
              <img src="./img/mine_two.jpg" alt="" className={styles.mine_imgl} />
              <div className={styles.mine_text}>客服热线</div>
          </div>
          <img src="./img/in.png" alt="" className={styles.mine_rig}/>
       </div>


        <div className={styles.mine_eve} onClick={()=>{
            axios.post(API_HOST+"/app/agent/getAgentInfo", {
                agentsId:getAgentsId()
              }
            ).then((res) => {
              if(res.data.code==="10000"){
                console.log(res)
                window.YLJsBridge.call(
                'callTel',
                {phoneNum:res.data.data.phone}
                )
              }
            })
          }}>
          <div className={styles.mine_left}>
              <img src="./img/mine_three.jpg" alt="" className={styles.mine_imgl} />
              <div className={styles.mine_text}>投诉电话</div>
          </div>
          <img src="./img/in.png" alt="" className={styles.mine_rig}/>
        </div>


        <div className={styles.mine_eve} onClick={()=>{this.props.history.push('/AboutUs')}}>
          <div className={styles.mine_left}>
              <img src="./img/mine_four.jpg" alt="" className={styles.mine_imgl} />
              <div className={styles.mine_text}>关于我们</div>
          </div>
          <img src="./img/in.png" alt="" className={styles.mine_rig}/>
        </div>

        {/* <div className={styles.mine_eve} onClick={()=>{this.props.history.push('/Test')}}>
          <div className={styles.mine_left}>
              <img src="./img/mine_four.jpg" alt="" className={styles.mine_imgl} />
              <div className={styles.mine_text}>测试</div>
          </div>
          <img src="./img/in.png" alt="" className={styles.mine_rig}/>
        </div> */}
</div>

{/*底部*/}
       <HomeBottom type={2} userId={this.props.global.userId} businessId={this.props.global.BusinessInfo.businessId}/>

</div>


    )
  }
  componentDidUpdate(){
    if(!this.state.isOk){
      if(this.props.global.BusinessInfo.agentsId){
        this.setState({loading:false,isOk:true})
        // window.YLJsBridge.call(
        //   'showRightItem',
        //   {isShow:false,message:"",iconType:4},
        //   (data)=>{})
      }

    }
  }

  componentDidMount(){
    const { dispatch } = this.props
    dispatch({
        type: 'global/setBusinessId',
        payload: {agentsId:getAgentsId()},
    })}


}
